using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace GemTowerDefence
{
  public class Sprite
  {
    public Vector2 Center { get; private set; }

    public Vector2 Position { get; set; }

    public float Rotation { get; set; }

    public Vector2 Velocity { get; set; }

    public Texture2D Texture { get; private set; }

    public Vector2 Origin { get; private set; }

    public Rectangle Bounds { get; set; }

    public Sprite(Texture2D tex, Vector2 pos)
    {
      Texture = tex;

      Position = pos;
      Velocity = Vector2.Zero;

      Center = new Vector2(Position.X + Texture.Width / 2F, Position.Y + Texture.Height / 2F);
      Origin = new Vector2(Texture.Width / 2F, Texture.Height / 2F);
      Bounds = new Rectangle((int)pos.X, (int)pos.Y, tex.Width, tex.Height);
    }

    public virtual void Update(GameTime gameTime)
    {
      Center = new Vector2(Position.X + Texture.Width / 2F, Position.Y + Texture.Height / 2F);
    }

    public virtual void Draw(SpriteBatch spriteBatch)
    {
      spriteBatch.Draw(Texture, Center, null, Color.White, Rotation, Origin, 1.0f, SpriteEffects.None, 0);
    }

    public virtual void Draw(SpriteBatch spriteBatch, Color color)
    {
      spriteBatch.Draw(Texture, Center, null, color, Rotation, Origin, 1.0f, SpriteEffects.None, 0);
    }

  }
}